<template>
  <div class="wait-handle-continer">
    <div class="list">
      <Card class="card" header v-for="(item, index) of list" :key="index">
        <template #header>
          <div class="top">
            <div class="customer-code">
              <div class="code">客户号码: {{ item.customerPhone }}</div>
            </div>
          </div>
        </template>

        <!-- 主体部分 -->
        <div class="content">
          <div class="field">
            <span class="name">工单时间</span>
            <span class="value">{{ item.createTime }}</span>
          </div>
          <div class="field">
            <span class="name">单元区域</span>
            <span class="value">{{ item.unit }}</span>
          </div>
          <div class="field">
            <span class="name">客户标识</span>
            <span class="value">{{ item.customerTag }}</span>
          </div>
          <div class="field">
            <span class="name">集团类别</span>
            <span class="value">{{ item.groupType }}</span>
          </div>
          <div class="field">
            <span class="name">集团名称</span>
            <span class="value">{{ item.groupName }}</span>
          </div>
        </div>

        <div class="footer">
          <div
            class="button"
            @click="onJump({ path: `/handleInfo`, query: { id: item.id } })"
          >
            去处理
          </div>
        </div>
      </Card>
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
const router = useRouter();

const onJump = (data) => {
  console.log(data);
  router.push(data);
};

import { omshFind } from "@/api/index";
import { showLoadingToast, showSuccessToast, closeToast } from "@/utils/toast";
import { onMounted, ref } from "vue";
const list = ref([]);

onMounted(async () => {
  showLoadingToast();
  list.value = (await omshFind()).result;
  closeToast();
});

onMounted(() => {
  fetchData();
});

// 把  方法“抛”出去
defineExpose({
  fetchData,
});

async function fetchData(data = {}) {
  showLoadingToast();
  list.value = (await omshFind(data)).result;
  closeToast();
}
</script>

<style lang="scss" scoped>
.list {
  display: flex;
  flex-direction: column;
  align-items: center;

  .card {
    margin-bottom: 16px;

    .top {
      display: flex;
      justify-content: space-between;

      .customer-code {
        display: flex;
        align-items: center;
        font-size: 15px;
        font-weight: 600;
      }
    }

    .content {
      .field {
        margin-top: 4px;
        display: flex;
        align-items: center;
        font-size: 13px;

        .name {
          font-weight: 400;
          white-space: nowrap;
        }

        .value {
          margin-left: 10px;
          color: #888;
        }

        &:first-child {
          margin-top: 0;
        }
      }
    }

    .footer {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 16px;
      width: 100%;

      &::after {
        content: "";
        position: absolute;
        top: 0;
        width: 100%;
        height: 1px;
        background: #eff3f8;
      }

      .button {
        margin-top: 12px;
        font-size: 16px;
        color: #409eff;
        font-weight: 600;
      }
    }
  }
}
</style>